/****************************************************
          File Name:main.c
          Author: Abby Cin
          Mail: abbytsing@gmail.com
          Created Time: Mon 10 Nov 2014 09:37:13 AM CST
*****************************************************/

#include "header.h"

int main(int argc, char *argv[])
{
	FILE *fp;
	unsigned int cap_frame = 0;
	
	if(argc < 3 || strcmp(argv[1], "--help") == 0)
	{
		fprintf(stderr, "%s output.yuv time(s) | %s video.yuv 10",argv[0],argv[0]);
		exit(EXIT_FAILURE);
	}
	
	cap_frame = (unsigned int)atoi(argv[2]) * 30;
	
	dev_open();
	
	dev_init();
	
	start_capture();
	
	fp = fopen(argv[1], "wa+");
	
	capture_time(cap_frame, fp);
	
	fclose(fp);
	
	stop_capture();
	
	dev_uninit();
	
	close(fd);
	
	exit(EXIT_SUCCESS);
}